ALMaSS  1.0
The Animal, Landscape and Man Simulation System
Rabbit_Population_Manager Class Reference

The class to handle all predator population related matters. More...

#include <Rabbit_Population_Manager.h>

Inheritance diagram for Rabbit_Population_Manager:
Population_Manager

Public Member Functions

 Rabbit_Population_Manager (Landscape *L)
 Rabbit_Population_Manager Constructor. More...
 
virtual ~Rabbit_Population_Manager (void)
 Rabbit_Population_Manager Destructor. More...
 
void CreateObjects (RabbitObjectTypes ob_type, TAnimal *pvo, struct_Rabbit *a_data, int a_number)
 Method for creating a new individual Rabbit. More...
 
TTypesOfRabbitHabitat ClassifyHabitat (TTypesOfLandscapeElement a_tole)
 Classify a landscape element type according to the rabbit habitat classification. More...
 
Rabbit_WarrenFindClosestWarren (int a_x, int a_y, int a_rank)
 Finds the closest warren as the crow flies. More...
 
void CheckForRabbitBreedingConditions (void)
 Determines whether it is breeding season. More...
 
bool IsBreedingSeason (void)
 Get whether it is breeding season. More...
 
void PesticideDeathRecord (RabbitObjectTypes ob_type)
 Records pesticide poisoning incidents. More...
 
unsigned SupplyAllBigRabbits ()
 Returns the total number of rabbits. More...
 
double GetGrowth (int a_age)
 Get method for the rabbit growth with age. More...
 
bool GetForageDay ()
 Get method for the forage day flag. More...
 
void ReproOutputRecordOutput (Rabbit_Female *a_female)
 Print reproductive record to file. More...
 
void NatalDispersalRecordOutput (Rabbit_Base *a_rabbit)
 Records the natal dispersal. More...
 
- Public Member Functions inherited from Population_Manager
 Population_Manager (Landscape *L)
 
virtual ~Population_Manager (void)
 
void SetNoProbes (int a_pn)
 
unsigned GetLiveArraySize (int a_listindex)
 Gets the number of 'live' objects for a list index in the TheArray. More...
 
void IncLiveArraySize (int a_listindex)
 Increments the number of 'live' objects for a list index in the TheArray. More...
 
virtual void Catastrophe (int)
 
unsigned int FarmAnimalCensus (unsigned int a_farm, unsigned int a_typeofanimal)
 
char * SpeciesSpecificReporting (int a_species, int a_time)
 
char * ProbeReport (int a_time)
 
char * ProbeReportTimed (int a_time)
 
void ImpactProbeReport (int a_Time)
 
bool BeginningOfMonth ()
 
void LOG (const char *fname)
 
int SupplyStepSize ()
 
int SupplySimW ()
 
int SupplySimH ()
 
virtual void Run (int NoTSteps)
 
virtual float Probe (int ListIndex, probe_data *p_TheProbe)
 
virtual void ImpactedProbe ()
 
int SupplyListNameLength ()
 
TAnimalSupplyAnimalPtr (int a_index, int a_animal)
 Returns the pointer indexed by a_index and a_animal. Note NO RANGE CHECK. More...
 
unsigned SupplyListIndexSize ()
 
unsigned SupplyListSize (unsigned listindex)
 
bool CheckXY (int l, int i)
 Debug method to test for out of bounds coordinates. More...
 
const char * SupplyListName (int i)
 
bool IsLast (unsigned listindex)
 
int SupplyState (unsigned listindex, unsigned j)
 
virtual void SupplyLocXY (unsigned listindex, unsigned j, int &x, int &y)
 
const char * SupplyStateNames (int i)
 
unsigned SupplyStateNamesLength ()
 
virtual void DisplayLocations ()
 
int ProbeFileInput (char *p_Filename, int p_ProbeNo)
 
TAnimalFindClosest (int x, int y, unsigned Type)
 
bool OpenTheRipleysOutputProbe (string a_NWordFilename)
 
void OpenTheAOROutputProbe (string a_AORFilename)
 
bool OpenTheMonthlyRipleysOutputProbe ()
 
bool OpenTheReallyBigProbe ()
 
virtual void TheRipleysOutputProbe (FILE *a_prb)
 
virtual void TheReallyBigOutputProbe ()
 
void CloseTheMonthlyRipleysOutputProbe ()
 
virtual void CloseTheRipleysOutputProbe ()
 
virtual void CloseTheReallyBigOutputProbe ()
 
TTypesOfPopulation GetPopulationType ()
 
int GetSeasonNumber ()
 Get the season number. More...
 
void LamdaDeath (int x, int y)
 
void LamdaBirth (int x, int y)
 
void LamdaBirth (int x, int y, int z)
 
void LamdaClear ()
 
void LamdaDumpOutput ()
 
virtual int SupplyPegPosx (int)
 
virtual int SupplyPegPosy (int)
 
virtual int SupplyCovPosx (int)
 
virtual int SupplyCovPosy (int)
 
virtual bool OpenTheFledgelingProbe ()
 
virtual bool OpenTheBreedingPairsProbe ()
 
virtual bool OpenTheBreedingSuccessProbe ()
 
virtual void BreedingPairsOutput (int)
 
virtual int TheBreedingFemalesProbe (int)
 
virtual int TheFledgelingProbe ()
 
virtual void BreedingSuccessProbeOutput (double, int, int, int, int, int, int, int)
 
virtual int TheBreedingSuccessProbe (int &, int &, int &, int &, int &, int &)
 
virtual void FledgelingProbeOutput (int, int)
 
virtual void TheGeneticProbe (unsigned, int, unsigned &)
 
virtual void GeneticsResultsOutput (FILE *, unsigned)
 

Protected Member Functions

virtual void DoFirst ()
 Things to do before anything else at the start of a timestep
More...
 
virtual void DoBefore ()
 Things to do before the Step. More...
 
virtual void DoAfter ()
 Things to do before the EndStep. More...
 
virtual void DoLast ()
 Things to do after the EndStep. More...
 
void PreProcessWarrenLocations ()
 This pre-scans the landscape and determines all potential warren locations on start-up. More...
 
bool WarrenLegalPos (int &a_x, int a_y)
 Tests the warrens list to see if this position is legal. More...
 
void SaveWarrenLocations (void)
 Save warren locations. More...
 
void LoadWarrenLocations (void)
 Load warren locations. More...
 
double AssessPctForage (int a_x, int a_y)
 Assesses the percentage of forage for a location assuming max warren size. More...
 
void CreateLocalWarrenNetworkLists (void)
 Forms the local warren network list for this warren. More...
 
void WarrenOccupancyRecordOutput ()
 Print warren occupancy record to file. More...
 
void PesticideDeathRecordOutput ()
 Print pesticide death record to file. More...
 
void PesticideDeathRecordOutputOpen ()
 Opens pesticide death output file. More...
 
void PesticideDeathRecordOutputClose ()
 Closes the pesticide death output file. More...
 
void WarrenOccupancyRecordOutputOpen ()
 Opens the warren occupancy output file. More...
 
void WarrenOccupancyRecordOutputClose ()
 Closes the warren occupancy output file. More...
 
void WarrenOutputAnalysis ()
 Does analysis on the warren output file and saves the results to RabbitPOMSummary.txt. More...
 
void LifetimeReproAnalysis ()
 Does analysis on the lifetime reproductive output file and saves the results to RabbitPOMSummary.txt. More...
 
void NatalDispersalAnalysis ()
 Does analysis on the natal dispersal output file and saves the results to RabbitPOMSummary.txt. More...
 
void ReproOutputRecordOutputOpen ()
 Opens the reproductive output file. More...
 
void ReproOutputRecordOutputClose ()
 Closes the reproductive output file. More...
 
void NatalDispersalRecordOutputOpen ()
 Opens the reproductive output file. More...
 
void NatalDispersalRecordOutputClose ()
 Closes the reproductive output file. More...
 
void AssignStaticVariables ()
 Assigns any static variables needing config variable assignment. More...
 
void TheAOROutputProbe ()
 
- Protected Member Functions inherited from Population_Manager
virtual bool StepFinished ()
 Overrides the population manager StepFinished - there is no chance that hunters do not finish a step behaviour. More...
 
virtual void DoAlmostLast ()
 
void EmptyTheArray ()
 Removes all objects from the TheArray by deleting them and clearing TheArray. More...
 
void SortX (unsigned Type)
 
void SortXIndex (unsigned Type)
 
void SortY (unsigned Type)
 
void SortState (unsigned Type)
 
void SortStateR (unsigned Type)
 
unsigned PartitionLiveDead (unsigned Type)
 
void Shuffle_or_Sort (unsigned Type)
 
void Shuffle (unsigned Type)
 
virtual void Catastrophe ()
 

Protected Attributes

int m_warrenfixedsize
 Holds an input variable for max warren size in m
More...
 
int m_warrenfixedsizediv2
 Half max warren size in m - for speed
More...
 
bool m_rabbitBreedingSeason
 The breeding season flag. More...
 
int m_reproswitchbuffer
 Prevents continuous breeding season switching. More...
 
double m_RabbitGrowth [3650]
 Holds daily growth potential of rabbits for each day
More...
 
int m_PesticideDeaths [rob_foobar]
 Holds the number of rabbits killed each day by pesticides. More...
 
ofstream m_WarrenOccupancyFile
 The warren occupancy output file. More...
 
ofstream m_NatalDispersalFile
 For recording the natal dispersal of adults from birth to death. More...
 
ofstream m_ReproOutputFile
 For recording the lifetime reproductive success. More...
 
ofstream m_PesticideDeathOFile
 The pesticide death output file. More...
 
bool m_forageday
 Flag to record whether today is a possible forage day. More...
 
- Protected Attributes inherited from Population_Manager
vector< unsigned > m_LiveArraySize
 
int m_NoProbes
 
AOR_Probem_AOR_Probe
 
FILE * m_GeneticsFile
 
FILE * m_AlleleFreqsFile
 
FILE * m_EasyPopRes
 
const char * StateNames [100]
 
int m_catastrophestartyear
 
int m_StepSize
 
vector< TListOfAnimalsTheArray
 
unsigned StateNamesLength
 
const char * m_ListNames [32]
 
unsigned m_ListNameLength
 
FILE * TestFile
 
FILE * TestFile2
 
unsigned BeforeStepActions [12]
 
int m_SeasonNumber
 Holds the season number. Used when running goose and hunter sims. More...
 
TTypesOfPopulation m_population_type
 
ofstream * AOROutputPrb
 
FILE * RipleysOutputPrb
 
FILE * RipleysOutputPrb1
 
FILE * RipleysOutputPrb2
 
FILE * RipleysOutputPrb3
 
FILE * RipleysOutputPrb4
 
FILE * RipleysOutputPrb5
 
FILE * RipleysOutputPrb6
 
FILE * RipleysOutputPrb7
 
FILE * RipleysOutputPrb8
 
FILE * RipleysOutputPrb9
 
FILE * RipleysOutputPrb10
 
FILE * RipleysOutputPrb11
 
FILE * RipleysOutputPrb12
 
FILE * ReallyBigOutputPrb
 
long int lamdagrid [2][257][257]
 

Additional Inherited Members

- Public Attributes inherited from Population_Manager
int IndexArrayX [5][10000]
 
probe_dataTheProbe [100]
 
int SimH
 
int SimW
 
unsigned SimHH
 
unsigned SimWH
 
char m_SimulationName [255]
 
bool ProbesSet
 
Landscapem_TheLandscape
 

Detailed Description

The class to handle all predator population related matters.

Constructor & Destructor Documentation

◆ Rabbit_Population_Manager()

Rabbit_Population_Manager::Rabbit_Population_Manager ( Landscape L)

Rabbit_Population_Manager Constructor.

Loads the list of Animal Classes.

Initialises global parameters/variables.

Creates some rabbits by introducing a number of male and female rabbits aged 100 to 365 days old. The number is defined by the input configuration variable cfg_StartNoRabbits.

The population manager needs to pre-process the landscape map for potential warren locations. This is very time consuming and so it is possible to read in a pre-processed list of locations. However, if this is done then it needs to be made very certain that the list being read in is the correct one for that landscape. No auto checking is possible.

120  : Population_Manager(L)
121 {
123  m_ListNames[0] = "Young";
124  m_ListNames[1] = "Juvenile";
125  m_ListNames[2] = "Male";
126  m_ListNames[3] = "Female";
127  m_ListNames[4] = "Possible Warrens";
128  m_ListNameLength = 5;
130  g_land_width = m_TheLandscape->SupplySimAreaWidth(); // Needs the landscape to be square!!!
131 
132  strcpy( m_SimulationName, "Rabbit Simulation" );
137  struct_Rabbit* sp = new struct_Rabbit;
138  sp->m_NPM = this;
139  sp->m_L = m_TheLandscape;
140  sp->m_age = 100+random(265);
141  sp->m_Warren = NULL;
142  sp->m_x2 = -1;
143  sp->m_y2 = -1;
144  sp->m_weightage = 300; // Should not be weak animals to start with
145 
146  for (int i = 0; i< cfg_RabbitStartNos.value(); i++)
147  {
148  sp->m_x = random(SimW);
149  sp->m_y = random(SimH);
150  CreateObjects(rob_Male,NULL,sp,1); //
151  }
152  for (int i=0; i< cfg_RabbitStartNos.value(); i++)
153  {
154  sp->m_x = random(SimW);
155  sp->m_y = random(SimH);
156  CreateObjects(rob_Female,NULL,sp,1); //
157  }
158  delete sp;
159  // Load parameters
164  m_reproswitchbuffer = 30;
165  m_rabbitBreedingSeason = false;
166 
172  {
174  }
175  else
176  {
179  }
181  // Open output files
184  }
189  // Assign static variable
191  // Create the rabbit growth rate lookup data
192  for (int i = 1; i < 300; i++) {
194  }
195  // Now fill this in for up to 10 years (no rabbit should ever live that long )
196  for (int i = 300; i < 3350; i++) {
198  }
199 
200 }
int random(int a_range)
Definition: ALMaSS_CmdLine.cpp:142
@ rob_Female
Definition: Rabbit.h:73
@ rob_Male
Definition: Rabbit.h:72
CfgBool cfg_RabbitUseReproOutput("RABBIT_USEREPROOUTPUT", CFG_CUSTOM, false)
Flag to denote using lifetime repro output file or not.
static CfgFloat cfg_rabbitdailygrowthparam1("RABBIT_DAILYGROWTHPARAM_ONE", CFG_CUSTOM, 1127.616084)
Input variable. Parameter one of the rabbit growth curve.
CfgFloat cfg_maxForageHeight
CfgBool cfg_RabbitUseNatalDispersalRecord("RABBIT_USENATALDISPERSALRECORD", CFG_CUSTOM, false)
Flag to denote using lifetime repro output file or not.
static CfgFloat cfg_rabbitdailygrowthparam3("RABBIT_DAILYGROWTHPARAM_THREE", CFG_CUSTOM, 0.0)
Input variable. Parameter three of the rabbit growth curve.
static CfgInt cfg_RabbitStartNos("RABBIT_STARTNOS", CFG_CUSTOM, 25000)
The starting number of rabbits.
CfgFloat cfg_dispersalmortperm
static CfgBool cfg_warrenreadlocations("RABBIT_WARRENREADLOCATIONS", CFG_CUSTOM, true)
Input variable. Should warren locations be calculated or read from a file?
CfgBool cfg_RipleysOutput_used
int g_land_width
Definition: Rabbit_Population_Manager.cpp:114
CfgInt cfg_warrenfixedsize("RABBIT_WARRENFIXEDSIZE", CFG_CUSTOM, 45)
Input variable. The maximum size for a warren (length m). Value is 45 for light soil 55 for heavy soi...
static CfgFloat cfg_rabbitdailygrowthparam2("RABBIT_DAILYGROWTHPARAM_TWO", CFG_CUSTOM, -0.013143202)
Input variable. Parameter two of the rabbit growth curve.
bool value(void)
Definition: configurator.h:135
double value(void)
Definition: configurator.h:118
int value(void)
Definition: configurator.h:98
int SupplySimAreaWidth(void)
Definition: landscape.h:1632
int SimH
Definition: PopulationManager.h:511
const char * m_ListNames[32]
Definition: PopulationManager.h:537
char m_SimulationName[255]
Definition: PopulationManager.h:513
Population_Manager(Landscape *L)
Definition: PopulationManager.cpp:221
bool OpenTheRipleysOutputProbe(string a_NWordFilename)
Definition: PopulationManager.cpp:757
unsigned m_ListNameLength
Definition: PopulationManager.h:538
int SimW
Definition: PopulationManager.h:511
Landscape * m_TheLandscape
Definition: PopulationManager.h:515
static double m_dispersalmortperm
The extra dispersal mortality per m travelled.
Definition: Rabbit.h:172
void CreateLocalWarrenNetworkLists(void)
Forms the local warren network list for this warren.
Definition: Rabbit_Population_Manager.cpp:640
void NatalDispersalRecordOutputOpen()
Opens the reproductive output file.
Definition: Rabbit_Population_Manager.cpp:923
double m_RabbitGrowth[3650]
Holds daily growth potential of rabbits for each day
Definition: Rabbit_Population_Manager.h:137
void PreProcessWarrenLocations()
This pre-scans the landscape and determines all potential warren locations on start-up.
Definition: Rabbit_Population_Manager.cpp:378
int m_reproswitchbuffer
Prevents continuous breeding season switching.
Definition: Rabbit_Population_Manager.h:135
int m_warrenfixedsizediv2
Half max warren size in m - for speed
Definition: Rabbit_Population_Manager.h:131
bool m_rabbitBreedingSeason
The breeding season flag.
Definition: Rabbit_Population_Manager.h:133
void CreateObjects(RabbitObjectTypes ob_type, TAnimal *pvo, struct_Rabbit *a_data, int a_number)
Method for creating a new individual Rabbit.
Definition: Rabbit_Population_Manager.cpp:250
int m_warrenfixedsize
Holds an input variable for max warren size in m
Definition: Rabbit_Population_Manager.h:129
void LoadWarrenLocations(void)
Load warren locations.
Definition: Rabbit_Population_Manager.cpp:610
void WarrenOccupancyRecordOutputOpen()
Opens the warren occupancy output file.
Definition: Rabbit_Population_Manager.cpp:872
void SaveWarrenLocations(void)
Save warren locations.
Definition: Rabbit_Population_Manager.cpp:588
void ReproOutputRecordOutputOpen()
Opens the reproductive output file.
Definition: Rabbit_Population_Manager.cpp:898
void AssignStaticVariables()
Assigns any static variables needing config variable assignment.
Definition: Rabbit_Population_Manager.cpp:203
void PesticideDeathRecordOutputOpen()
Opens pesticide death output file.
Definition: Rabbit_Population_Manager.cpp:866
static double m_maxForageHeight
The maximum vegetation height assumed for forage potential.
Definition: Rabbit.h:541
Used for creation of a new Rabbit object.
Definition: Rabbit_Population_Manager.h:59
Rabbit_Population_Manager * m_NPM
Rabbit_Population_Manager pointer.
Definition: Rabbit_Population_Manager.h:72
int m_y
y-coord
Definition: Rabbit_Population_Manager.h:64
int m_x2
x-coord of birth
Definition: Rabbit_Population_Manager.h:66
int m_age
The rabbit age.
Definition: Rabbit_Population_Manager.h:74
Rabbit_Warren * m_Warren
A pointer to the current warren.
Definition: Rabbit_Population_Manager.h:80
int m_y2
y-coord of birth
Definition: Rabbit_Population_Manager.h:68
Landscape * m_L
Landscape pointer.
Definition: Rabbit_Population_Manager.h:70
int m_weightage
The rabbit age in terms of weight.
Definition: Rabbit_Population_Manager.h:76
int m_x
x-coord
Definition: Rabbit_Population_Manager.h:62

References AssignStaticVariables(), cfg_dispersalmortperm, cfg_maxForageHeight, cfg_rabbitdailygrowthparam1, cfg_rabbitdailygrowthparam2, cfg_rabbitdailygrowthparam3, cfg_RabbitStartNos, cfg_RabbitUseNatalDispersalRecord, cfg_RabbitUseReproOutput, cfg_RipleysOutput_used, cfg_warrenfixedsize, cfg_warrenreadlocations, CreateLocalWarrenNetworkLists(), CreateObjects(), g_land_width, LoadWarrenLocations(), struct_Rabbit::m_age, Rabbit_Base::m_dispersalmortperm, struct_Rabbit::m_L, Population_Manager::m_ListNameLength, Population_Manager::m_ListNames, Rabbit_Warren::m_maxForageHeight, struct_Rabbit::m_NPM, m_rabbitBreedingSeason, m_RabbitGrowth, m_reproswitchbuffer, Population_Manager::m_SimulationName, Population_Manager::m_TheLandscape, struct_Rabbit::m_Warren, m_warrenfixedsize, m_warrenfixedsizediv2, struct_Rabbit::m_weightage, struct_Rabbit::m_x, struct_Rabbit::m_x2, struct_Rabbit::m_y, struct_Rabbit::m_y2, NatalDispersalRecordOutputOpen(), Population_Manager::OpenTheRipleysOutputProbe(), PesticideDeathRecordOutputOpen(), PreProcessWarrenLocations(), random(), ReproOutputRecordOutputOpen(), rob_Female, rob_Male, SaveWarrenLocations(), Population_Manager::SimH, Population_Manager::SimW, Landscape::SupplySimAreaWidth(), CfgInt::value(), CfgFloat::value(), CfgBool::value(), and WarrenOccupancyRecordOutputOpen().

◆ ~Rabbit_Population_Manager()

Rabbit_Population_Manager::~Rabbit_Population_Manager ( void  )
virtual

Rabbit_Population_Manager Destructor.

Closes the output files created specially for rabbit output. Calls post run analysis routines and then empties any active rabbits from the TheArray deleting the respective rabbit objects.

226 {
235  }
239  }
241  for (unsigned i = 0; i < TheArray.size(); i++) {
242  for ( unsigned j = 0; j < TheArray[ i ].size(); j++ ) {
243  // This just stops a DEBUG error
244  TheArray[ i ] [ j ]->KillThis();
245  }
246  }
247 }
vector< TListOfAnimals > TheArray
Definition: PopulationManager.h:534
void LifetimeReproAnalysis()
Does analysis on the lifetime reproductive output file and saves the results to RabbitPOMSummary....
Definition: Rabbit_Population_Manager.cpp:1061
void ReproOutputRecordOutputClose()
Closes the reproductive output file.
Definition: Rabbit_Population_Manager.cpp:906
void NatalDispersalAnalysis()
Does analysis on the natal dispersal output file and saves the results to RabbitPOMSummary....
Definition: Rabbit_Population_Manager.cpp:1133
void WarrenOccupancyRecordOutputClose()
Closes the warren occupancy output file.
Definition: Rabbit_Population_Manager.cpp:937
void PesticideDeathRecordOutputClose()
Closes the pesticide death output file.
Definition: Rabbit_Population_Manager.cpp:882
void WarrenOutputAnalysis()
Does analysis on the warren output file and saves the results to RabbitPOMSummary....
Definition: Rabbit_Population_Manager.cpp:943
void NatalDispersalRecordOutputClose()
Closes the reproductive output file.
Definition: Rabbit_Population_Manager.cpp:931

References cfg_RabbitUseNatalDispersalRecord, cfg_RabbitUseReproOutput, LifetimeReproAnalysis(), NatalDispersalAnalysis(), NatalDispersalRecordOutputClose(), PesticideDeathRecordOutputClose(), ReproOutputRecordOutputClose(), Population_Manager::TheArray, CfgBool::value(), WarrenOccupancyRecordOutputClose(), and WarrenOutputAnalysis().

Member Function Documentation

◆ AssessPctForage()

double Rabbit_Population_Manager::AssessPctForage ( int  a_x,
int  a_y 
)
protected

Assesses the percentage of forage for a location assuming max warren size.

/**

Parameters
[in]a_xthe x coordinate for the TL corner of the warren.
[in]a_ythe y coordinate for the TL corner of the warren.
Returns
The % of are covered by permanent forage.

Loops through the potential warren area and find all the forage and sums this. Then calculate the percentage.

This is done by getting the polygon references and checking if we had this one already. If not save it with an area of 1 otherwise increment the correct record by 1.

Returns the total forage area divided by the total warren area.

553 {
561  int total = 0;
562  int add = 0;
563  int oldpoly = -1;
564  for (int i=a_x; i<a_x + m_warrenfixedsize; i++)
565  {
566  for (int j=a_y; j<a_y + m_warrenfixedsize; j++)
567  {
571  int poly = m_TheLandscape->SupplyPolyRef(i, j);
572  if (poly != oldpoly)
573  {
574  oldpoly = poly;
576  if (ClassifyHabitat(tole) == torh_Forage) add = 1; else add = 0;
577  }
578  total += add;
579  }
580  }
581  double warrenarea = m_warrenfixedsize * m_warrenfixedsize;
585  return (double) total/warrenarea;
586 }
@ torh_Forage
Definition: Rabbit.h:103
int SupplyPolyRef(int a_x, int a_y)
Definition: landscape.h:1488
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1110
TTypesOfRabbitHabitat ClassifyHabitat(TTypesOfLandscapeElement a_tole)
Classify a landscape element type according to the rabbit habitat classification.
Definition: Rabbit_Population_Manager.cpp:457
TTypesOfLandscapeElement
Definition: tole_declaration.h:36

References ClassifyHabitat(), Population_Manager::m_TheLandscape, m_warrenfixedsize, Landscape::SupplyElementType(), Landscape::SupplyPolyRef(), and torh_Forage.

Referenced by PreProcessWarrenLocations().

◆ AssignStaticVariables()

void Rabbit_Population_Manager::AssignStaticVariables ( void  )
protected

Assigns any static variables needing config variable assignment.

This is just needed to make the C++ work. Default variables are assigned to static members at start-up, but any that we actually want to get configuration variable values have to be dealt with here

204 {
207  struct_Rabbit* sp = new struct_Rabbit;
208  sp->m_NPM = this;
209  sp->m_L = m_TheLandscape;
210  sp->m_age = 100 + random(265);
211  sp->m_Warren = NULL;
212  Rabbit_Female* rf = new Rabbit_Female(0,0,-1,-1,m_TheLandscape,this,0, 300,NULL);
213  Rabbit_Warren* rw = new Rabbit_Warren(0, 0, m_TheLandscape, this, 0, NULL);
218  rf->SetMaxKits(cfg_rabbitmaxkits.value() - cfg_rabbitminkits.value()); // Here we actually use the difference to calculate range
219  rf->m_pesticidedegradationrate = cfg_rabbit_pesticidedegradationrate.value(); // default of 0.0 will remove all body burden pesticide at the end of each day
220  delete rw;
221  delete rf;
222 }
CfgFloat cfg_rabbitmaxkits
CfgFloat cfg_rabbit_pesticidedegradationrate
CfgFloat cfg_minForageDigestability
CfgFloat cfg_rabbitminkits
static double m_pesticidedegradationrate
State variable used to hold the daily degredation rate of the pesticide in the body.
Definition: Rabbit.h:174
The rabbit female class. All special female behaviour is described here.
Definition: Rabbit.h:444
void SetMaxKits(double a_num)
Definition: Rabbit.h:463
void SetMinKits(double a_num)
Definition: Rabbit.h:462
A class to describe the rabbits warren system.
Definition: Rabbit.h:519
static double m_minForageDigestability
The minimum vegetation digestability allowed for foraging.
Definition: Rabbit.h:543

References cfg_dispersalmortperm, cfg_maxForageHeight, cfg_minForageDigestability, cfg_rabbit_pesticidedegradationrate, cfg_rabbitmaxkits, cfg_rabbitminkits, struct_Rabbit::m_age, Rabbit_Base::m_dispersalmortperm, struct_Rabbit::m_L, Rabbit_Warren::m_maxForageHeight, Rabbit_Warren::m_minForageDigestability, struct_Rabbit::m_NPM, Rabbit_Base::m_pesticidedegradationrate, Population_Manager::m_TheLandscape, struct_Rabbit::m_Warren, random(), Rabbit_Female::SetMaxKits(), Rabbit_Female::SetMinKits(), and CfgFloat::value().

Referenced by Rabbit_Population_Manager().

◆ CheckForRabbitBreedingConditions()

void Rabbit_Population_Manager::CheckForRabbitBreedingConditions ( void  )

Determines whether it is breeding season.

736 {
737  /*
738  * Once the temperature comes up over a certain trigger the breeding seasons starts. Rapid switching is prevented by not making the test again for 120 days.
739  * When the temperature in the future drops down again then the breeding season stops
740  */
741  if (--m_reproswitchbuffer > 0) return;
742 
744  {
746  {
747  m_reproswitchbuffer = 120;
748  m_rabbitBreedingSeason = true;
749 #ifdef __RABBITBREEDINGSEASONCHECK
750  cout << g_date->GetYearNumber() << " " << g_date->DayInYear() << " " << m_TheLandscape->SupplyTempPeriod( g_date->Date()+60, 60 ) << " - " << "Started" << endl;
751 #endif
752  }
753  }
754  else
755  {
757  {
758  m_reproswitchbuffer = 90;
759  m_rabbitBreedingSeason = false;
760 #ifdef __RABBITBREEDINGSEASONCHECK
761  cout << g_date->GetYearNumber() << " " << g_date->DayInYear() << " " << m_TheLandscape->SupplyTempPeriod( g_date->Date()+30, 90 ) << " - " << "Stopped" << endl;
762 #endif
763  }
764  }
765 }
static CfgFloat cfg_rabbitminbreedingtemp("RABBIT_MINBREEDINGTEMP", CFG_CUSTOM, 300.0)
Input variable. The minimum 60 day average temperature for rabbit breeding.
class Calendar * g_date
Definition: calendar.cpp:38
long Date(void)
Definition: calendar.h:57
int GetYearNumber(void)
Definition: calendar.h:68
int DayInYear(void)
Definition: calendar.h:58
double SupplyTempPeriod(long a_date, int a_period)
Definition: landscape.h:1410

References cfg_rabbitminbreedingtemp, Calendar::Date(), Calendar::DayInYear(), g_date, Calendar::GetYearNumber(), m_rabbitBreedingSeason, m_reproswitchbuffer, Population_Manager::m_TheLandscape, Landscape::SupplyTempPeriod(), and CfgFloat::value().

Referenced by DoFirst().

◆ ClassifyHabitat()

TTypesOfRabbitHabitat Rabbit_Population_Manager::ClassifyHabitat ( TTypesOfLandscapeElement  a_tole)

Classify a landscape element type according to the rabbit habitat classification.

Parameters
[in]a_toleThe type of landscape element
Returns
The type of rabbit habitat represented by the landscape element type.

This is basically a translation function from the element type from the landscape map to the type of habitat it represents for the rabbit. This makes no assessment of the vegetation on the element though.

458 {
466  static char error_num[ 20 ];
467  switch (a_tole)
468  {
469  case tole_UnsprayedFieldMargin://31
470  case tole_Field://20&30
471  case tole_RoadsideVerge://13
472  case tole_BeetleBank://141
473  return torh_TemporaryForage;
474  break;
475  case tole_Railway://118
476  case tole_FieldBoundary://160
477  case tole_PermPastureLowYield://26
478  case tole_PermPastureTussocky://27
479  case tole_PermanentSetaside://33
480  case tole_PermPasture://35
481  case tole_NaturalGrassDry://110//case tole11
482  case tole_PitDisused://75
483  case tole_YoungForest://55
484  case tole_HedgeBank://140
485  case tole_Heath://94
486  case tole_Parkland://14
487  case tole_SandDune://101
488  case tole_Orchard://56
489  case tole_RoadsideSlope: //201
490  case tole_HeritageSite: //208
491  case tole_UnknownGrass:
492  case tole_Vildtager:
493  case tole_MownGrass:
494  case tole_Wasteland:
495  return torh_Forage;
496  break;
497  case tole_Hedges://130
498  case tole_Copse://41
499  case tole_Scrub://70
500  case tole_RiversideTrees://97
501  case tole_DeciduousForest://40
502  case tole_MixedForest://60
503  case tole_ConiferousForest://50
504  case tole_WoodlandMargin:
506  return torh_Cover;
507  break;
508  case tole_UrbanPark: //17
510  case tole_Churchyard: //204
511  case tole_Saltmarsh: //206
512  case tole_Stream: //207
513  case tole_Carpark: //203
514  case tole_IndividualTree: //42
515  case tole_MetalledPath: //202
516  case tole_StoneWall://15
517  case tole_Fence: //225
518  case tole_Garden://11//case tole20
519  case tole_Track://123
520  case tole_SmallRoad://122
521  case tole_LargeRoad://121
522  case tole_Building://5
523  case tole_ActivePit://115
524  case tole_Pond:
525  case tole_Freshwater://90
526  case tole_FishFarm:
527  case tole_River://96
528  case tole_Saltwater://80
529  case tole_Coast://100
530  case tole_UrbanNoVeg://8
531  case tole_BuiltUpWithParkland://16
532  case tole_AmenityGrass://12
533  case tole_OrchardBand://57
534  case tole_BareRock://59
535  case tole_Marsh://95
536  case tole_RiversidePlants://98
537  case tole_PlantNursery:
538  case tole_Pylon:
539  case tole_WindTurbine:
541  return torh_Other;
542  break;
543  default:
544  sprintf( error_num, "%d", a_tole );
545  m_TheLandscape->Warn("Rabbit_Warren::InitEvaluation Unknown tole type: ", error_num);
546  exit(1);
547  break;
548  }
549 }
@ torh_Cover
Definition: Rabbit.h:105
@ torh_Other
Definition: Rabbit.h:106
@ torh_TemporaryForage
Definition: Rabbit.h:104
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1579
@ tole_BareRock
Definition: tole_declaration.h:75
@ tole_PermPastureTussocky
Definition: tole_declaration.h:45
@ tole_Saltmarsh
Definition: tole_declaration.h:88
@ tole_WoodyEnergyCrop
Definition: tole_declaration.h:94
@ tole_Carpark
Definition: tole_declaration.h:85
@ tole_Coast
Definition: tole_declaration.h:67
@ tole_UrbanNoVeg
Definition: tole_declaration.h:78
@ tole_Stream
Definition: tole_declaration.h:89
@ tole_Saltwater
Definition: tole_declaration.h:66
@ tole_MixedForest
Definition: tole_declaration.h:53
@ tole_HeritageSite
Definition: tole_declaration.h:90
@ tole_WoodlandMargin
Definition: tole_declaration.h:98
@ tole_RoadsideSlope
Definition: tole_declaration.h:83
@ tole_River
Definition: tole_declaration.h:65
@ tole_StoneWall
Definition: tole_declaration.h:56
@ tole_Parkland
Definition: tole_declaration.h:77
@ tole_NaturalGrassWet
Definition: tole_declaration.h:87
@ tole_NaturalGrassDry
Definition: tole_declaration.h:48
@ tole_PermPastureTussockyWet
Definition: tole_declaration.h:100
@ tole_UrbanPark
Definition: tole_declaration.h:79
@ tole_Pylon
Definition: tole_declaration.h:96
@ tole_PermanentSetaside
Definition: tole_declaration.h:46
@ tole_Garden
Definition: tole_declaration.h:58
@ tole_Pond
Definition: tole_declaration.h:101
@ tole_Scrub
Definition: tole_declaration.h:42
@ tole_Fence
Definition: tole_declaration.h:57
@ tole_Field
Definition: tole_declaration.h:43
@ tole_Copse
Definition: tole_declaration.h:82
@ tole_PermPasture
Definition: tole_declaration.h:47
@ tole_Hedges
Definition: tole_declaration.h:37
@ tole_Track
Definition: tole_declaration.h:59
@ tole_Heath
Definition: tole_declaration.h:70
@ tole_Freshwater
Definition: tole_declaration.h:64
@ tole_PitDisused
Definition: tole_declaration.h:50
@ tole_FieldBoundary
Definition: tole_declaration.h:40
@ tole_PlantNursery
Definition: tole_declaration.h:95
@ tole_DeciduousForest
Definition: tole_declaration.h:52
@ tole_ActivePit
Definition: tole_declaration.h:63
@ tole_RiversidePlants
Definition: tole_declaration.h:49
@ tole_Building
Definition: tole_declaration.h:62
@ tole_RoadsideVerge
Definition: tole_declaration.h:38
@ tole_Vildtager
Definition: tole_declaration.h:99
@ tole_Orchard
Definition: tole_declaration.h:71
@ tole_MownGrass
Definition: tole_declaration.h:74
@ tole_YoungForest
Definition: tole_declaration.h:55
@ tole_OrchardBand
Definition: tole_declaration.h:73
@ tole_SmallRoad
Definition: tole_declaration.h:60
@ tole_Churchyard
Definition: tole_declaration.h:86
@ tole_BuiltUpWithParkland
Definition: tole_declaration.h:80
@ tole_AmenityGrass
Definition: tole_declaration.h:76
@ tole_PermPastureLowYield
Definition: tole_declaration.h:44
@ tole_HedgeBank
Definition: tole_declaration.h:68
@ tole_Railway
Definition: tole_declaration.h:39
@ tole_WindTurbine
Definition: tole_declaration.h:97
@ tole_ConiferousForest
Definition: tole_declaration.h:54
@ tole_SandDune
Definition: tole_declaration.h:81
@ tole_Wasteland
Definition: tole_declaration.h:92
@ tole_IndividualTree
Definition: tole_declaration.h:93
@ tole_UnknownGrass
Definition: tole_declaration.h:91
@ tole_RiversideTrees
Definition: tole_declaration.h:51
@ tole_LargeRoad
Definition: tole_declaration.h:61
@ tole_UnsprayedFieldMargin
Definition: tole_declaration.h:72
@ tole_BeetleBank
Definition: tole_declaration.h:69
@ tole_MetalledPath
Definition: tole_declaration.h:84
@ tole_FishFarm
Definition: tole_declaration.h:102
@ tole_Marsh
Definition: tole_declaration.h:41

References Population_Manager::m_TheLandscape, tole_ActivePit, tole_AmenityGrass, tole_BareRock, tole_BeetleBank, tole_Building, tole_BuiltUpWithParkland, tole_Carpark, tole_Churchyard, tole_Coast, tole_ConiferousForest, tole_Copse, tole_DeciduousForest, tole_Fence, tole_Field, tole_FieldBoundary, tole_FishFarm, tole_Freshwater, tole_Garden, tole_Heath, tole_HedgeBank, tole_Hedges, tole_HeritageSite, tole_IndividualTree, tole_LargeRoad, tole_Marsh, tole_MetalledPath, tole_MixedForest, tole_MownGrass, tole_NaturalGrassDry, tole_NaturalGrassWet, tole_Orchard, tole_OrchardBand, tole_Parkland, tole_PermanentSetaside, tole_PermPasture, tole_PermPastureLowYield, tole_PermPastureTussocky, tole_PermPastureTussockyWet, tole_PitDisused, tole_PlantNursery, tole_Pond, tole_Pylon, tole_Railway, tole_River, tole_RiversidePlants, tole_RiversideTrees, tole_RoadsideSlope, tole_RoadsideVerge, tole_Saltmarsh, tole_Saltwater, tole_SandDune, tole_Scrub, tole_SmallRoad, tole_StoneWall, tole_Stream, tole_Track, tole_UnknownGrass, tole_UnsprayedFieldMargin, tole_UrbanNoVeg, tole_UrbanPark, tole_Vildtager, tole_Wasteland, tole_WindTurbine, tole_WoodlandMargin, tole_WoodyEnergyCrop, tole_YoungForest, torh_Cover, torh_Forage, torh_Other, torh_TemporaryForage, and Landscape::Warn().

Referenced by AssessPctForage(), Rabbit_Warren::InitEvaluation(), and WarrenLegalPos().

◆ CreateLocalWarrenNetworkLists()

void Rabbit_Population_Manager::CreateLocalWarrenNetworkLists ( void  )
protected

Forms the local warren network list for this warren.

Loops through all warrens in a double loop and checks if any warrens are within maxWarrenNetworkDist of each other. If so then they are added to the warren local network for that warren. If no warrens are close, then the nearest one is added, so that the list is not empty. This is not optimised because it is only called once - of course it could be done faster.

641 {
646  int sz = (int) TheArray[rob_Warren].size();
647  for (int i=0; i< sz; i++)
648  {
649  int closest = -1;
650  int dist = SimH;
651  int mDist = SimH;
652  int ourX = TheArray[rob_Warren][i]->Supply_m_Location_x();
653  int ourY = TheArray[rob_Warren][i]->Supply_m_Location_y();
654  for (int j=0; j< sz; j++)
655  {
656  if (i!=j) // Don't add ourselves
657  {
658  int theirX = TheArray[rob_Warren][j]->Supply_m_Location_x();
659  int theirY = TheArray[rob_Warren][j]->Supply_m_Location_y();
660  dist = (int) sqrt( (double)(((theirX-ourX)*(theirX-ourX)) + ((theirY-ourY)*(theirY - ourY))) );
661  if (dist < cfg_maxWarrenNetworkDist.value())
662  {
663  // Add to the network for this warren
665  LWNE.m_aWarren = dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][j]);
666  LWNE.m_dist = dist;
667  dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][i])->AddNetworkConnection( LWNE );
668  }
669  if (dist < mDist)
670  {
671  mDist = dist;
672  closest = j;
673  }
674  }
675  }
676  if (dist > cfg_maxWarrenNetworkDist.value())
677  {
678  // Add the closest warren since there are no others
680  LWNE.m_aWarren = dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][closest]);
681  LWNE.m_dist = dist;
682  dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][i])->AddNetworkConnection( LWNE );
683  }
684  }
685  for (int i=0; i< sz; i++)
686  {
687  dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][i])->NetworkEvaluation();
688  }
689 }
@ rob_Warren
Definition: Rabbit.h:74
static CfgInt cfg_maxWarrenNetworkDist("RABBIT_MAXWARRENNETWORKDIST", CFG_CUSTOM, 1500)
Input variable. The maximum distance between directly connected warrens.
An entry in the local warren network - a helper list of accessibly local warren locations.
Definition: Rabbit.h:141
int m_dist
Definition: Rabbit.h:143
Rabbit_Warren * m_aWarren
Definition: Rabbit.h:142

References cfg_maxWarrenNetworkDist, LocalWarrenNewtorkEntry::m_aWarren, LocalWarrenNewtorkEntry::m_dist, rob_Warren, Population_Manager::SimH, Population_Manager::TheArray, and CfgInt::value().

Referenced by Rabbit_Population_Manager().

◆ CreateObjects()

void Rabbit_Population_Manager::CreateObjects ( RabbitObjectTypes  ob_type,
TAnimal pvo,
struct_Rabbit a_data,
int  a_number 
)

Method for creating a new individual Rabbit.

Parameters
[in]ob_typeThe type of rabbit to create.
[in]pvounused unless a young is created in which case this points to the mother.
[in]a_dataA data structure containing the information needed to create the rabbit object.
[in]a_numberThe number of objects to create using a_data.

Creates a_number of new rabbit objects of type ob_type using the information about the rabbit passed in a_data. All rabbit objects created are added to the appropriate rabbit lists held in TheArray. Note that rabbit warrens are also created here to take advantage of the code in TAnimal and population manager handling - I know they are not actually rabbits themselves :)

Warren size is assumed to be 4x the fixed area, this is because low fixed area means low change of less than 100% forage, and rabbits forage quite a distance from the burrow

251 {
261  switch (ob_type)
262  {
263  case rob_Young:
264  Rabbit_Young* new_RabbitY;
265  for (int i=0; i<a_number; i++)
266  {
267  new_RabbitY = new Rabbit_Young(a_data->m_x, a_data->m_y, a_data->m_x2, a_data->m_y2, dynamic_cast<Rabbit_Female*>(pvo), a_data->m_L, a_data->m_NPM, a_data->m_Warren);
268  TheArray[ob_type].push_back(new_RabbitY);
269  dynamic_cast<Rabbit_Female*>(pvo)->AddYoung(new_RabbitY);
270  }
271  break;
272  case rob_Juvenile:
273  Rabbit_Juvenile* new_RabbitJ;
274  for (int i=0; i<a_number; i++)
275  {
276  new_RabbitJ = new Rabbit_Juvenile(a_data->m_x, a_data->m_y, a_data->m_x2, a_data->m_y2, dynamic_cast<Rabbit_Female*>(pvo), a_data->m_L, a_data->m_NPM, a_data->m_age, a_data->m_weightage, a_data->m_Warren);
277  TheArray[ob_type].push_back(new_RabbitJ);
278  }
279  break;
280  case rob_Male:
281  Rabbit_Male* new_RabbitM;
282  for (int i=0; i<a_number; i++)
283  {
284  new_RabbitM = new Rabbit_Male(a_data->m_x, a_data->m_y, a_data->m_x2, a_data->m_y2, a_data->m_L, a_data->m_NPM, a_data->m_age, a_data->m_weightage, a_data->m_Warren);
285  TheArray[ob_type].push_back(new_RabbitM);
286  }
287  break;
288  case rob_Female:
289  Rabbit_Female* new_RabbitF;
290  for (int i=0; i<a_number; i++)
291  {
292  new_RabbitF = new Rabbit_Female(a_data->m_x, a_data->m_y, a_data->m_x2, a_data->m_y2, a_data->m_L, a_data->m_NPM, a_data->m_age, a_data->m_weightage, a_data->m_Warren);
293  TheArray[ob_type].push_back(new_RabbitF);
294  }
295  break;
296  case rob_Warren:
297  Rabbit_Warren* new_RabbitW;
298  for (int i=0; i<a_number; i++)
299  {
303  new_RabbitW = new Rabbit_Warren(a_data->m_x, a_data->m_y, a_data->m_L, a_data->m_NPM, m_warrenfixedsize, a_data->m_soil);
304  if (new_RabbitW->GetCarryingCapacity()>0) TheArray[ob_type].push_back(new_RabbitW);
305  else delete new_RabbitW;
306  }
307  break;
308  }
309 }
@ rob_Young
Definition: Rabbit.h:70
@ rob_Juvenile
Definition: Rabbit.h:71
The rabbit juvenile class. All special juvenile behaviour is described here.
Definition: Rabbit.h:348
The rabbit male class. All special male behaviour is described here.
Definition: Rabbit.h:423
int GetCarryingCapacity()
Returns the carrying capacity in burrows.
Definition: Rabbit.h:578
The rabbit young class. All special young behaviour is described here.
Definition: Rabbit.h:320
int m_soil
The current warren soil type.
Definition: Rabbit_Population_Manager.h:82

References Rabbit_Warren::GetCarryingCapacity(), struct_Rabbit::m_age, struct_Rabbit::m_L, struct_Rabbit::m_NPM, struct_Rabbit::m_soil, struct_Rabbit::m_Warren, m_warrenfixedsize, struct_Rabbit::m_weightage, struct_Rabbit::m_x, struct_Rabbit::m_x2, struct_Rabbit::m_y, struct_Rabbit::m_y2, rob_Female, rob_Juvenile, rob_Male, rob_Warren, rob_Young, and Population_Manager::TheArray.

Referenced by DoFirst(), LoadWarrenLocations(), PreProcessWarrenLocations(), Rabbit_Population_Manager(), Rabbit_Juvenile::st_BecomeAdult(), Rabbit_Young::st_BecomeJuvenile(), and Rabbit_Female::st_GiveBirth().

◆ DoAfter()

virtual void Rabbit_Population_Manager::DoAfter ( )
inlineprotectedvirtual

Things to do before the EndStep.

Reimplemented from Population_Manager.

156 {}

◆ DoBefore()

virtual void Rabbit_Population_Manager::DoBefore ( void  )
inlineprotectedvirtual

Things to do before the Step.

Reimplemented from Population_Manager.

154 {}

◆ DoFirst()

void Rabbit_Population_Manager::DoFirst ( void  )
protectedvirtual

Things to do before anything else at the start of a timestep

Reimplemented from Population_Manager.

313 {
314 #ifdef __RABBITDEBUG2
315  if (m_TheLandscape->SupplyYearNumber()== 1000)
316  if (m_TheLandscape->SupplyDayInYear() == 1) {
321  struct_Rabbit* sp = new struct_Rabbit;
322  sp->m_NPM = this;
323  sp->m_L = m_TheLandscape;
324  sp->m_age = 100 + random( 265 );
325  sp->m_Warren = NULL;
326  sp->m_x2 = -1;
327  sp->m_y2 = -1;
328  sp->m_weightage = 300; // Should not be weak animals to start with
329 
330  for (int i = 0; i< 500; i++) {
331  sp->m_x = random( SimW );
332  sp->m_y = random( SimH );
333  CreateObjects( rob_Male, NULL, sp, 1 ); //
334  }
335  for (int i = 0; i< 500; i++) {
336  sp->m_x = random( SimW );
337  sp->m_y = random( SimH );
338  CreateObjects( rob_Female, NULL, sp, 1 ); //
339  }
340  delete sp;
341  }
342 #endif
344  for (int r = (int)rob_Young; r < (int)rob_foobar; r++)
345  {
346  m_PesticideDeaths[r] = 0;
347  }
348  // Manage warren disease
350  {
351  for (unsigned i = 0; i < TheArray[rob_Warren].size(); i++) dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][i])->CalcDisease();
352  }
353  // Determine whether today is forage day
354  double rainfall = m_TheLandscape->SupplyRain();
355  double temp = m_TheLandscape->SupplyTemp();
356  if ((temp<cfg_rabbitminimumforagetemp.value()) || (rainfall>cfg_rabbitmaxforagerainfall.value())) m_forageday = false; else m_forageday = true;
357 }
@ rob_foobar
Definition: Rabbit.h:75
static CfgFloat cfg_rabbitminimumforagetemp("RABBIT_MINFORAGETEMP", CFG_CUSTOM, -0.83)
Input variable. The minimum forage temperature for rabbits.
CfgInt cfg_rabbitdiseasedensitydependencedelay("RABBITDISEASEDENDEPPERIOD", CFG_CUSTOM, 90)
Input variable. The period between recalculation of rabbit disease probability.
static CfgFloat cfg_rabbitmaxforagerainfall("RABBIT_MAXFORAGERAINFALL", CFG_CUSTOM, 3.6)
Input variable. The maximum rainfall before rabbits are assumed not to forage.
int SupplyYearNumber(void)
Definition: landscape.h:1616
double SupplyTemp(void)
Definition: landscape.h:1386
double SupplyRain(void)
Definition: landscape.h:1365
int SupplyDayInYear(void)
Definition: landscape.h:1596
bool m_forageday
Flag to record whether today is a possible forage day.
Definition: Rabbit_Population_Manager.h:149
int m_PesticideDeaths[rob_foobar]
Holds the number of rabbits killed each day by pesticides.
Definition: Rabbit_Population_Manager.h:139
void CheckForRabbitBreedingConditions(void)
Determines whether it is breeding season.
Definition: Rabbit_Population_Manager.cpp:735
void CalcDisease()
Calculate the current disease mortality constant.
Definition: Rabbit.cpp:1583

References Rabbit_Warren::CalcDisease(), cfg_rabbitdiseasedensitydependencedelay, cfg_rabbitmaxforagerainfall, cfg_rabbitminimumforagetemp, CheckForRabbitBreedingConditions(), CreateObjects(), struct_Rabbit::m_age, m_forageday, struct_Rabbit::m_L, struct_Rabbit::m_NPM, m_PesticideDeaths, Population_Manager::m_TheLandscape, struct_Rabbit::m_Warren, struct_Rabbit::m_weightage, struct_Rabbit::m_x, struct_Rabbit::m_x2, struct_Rabbit::m_y, struct_Rabbit::m_y2, random(), rob_Female, rob_foobar, rob_Male, rob_Warren, rob_Young, Population_Manager::SimH, Population_Manager::SimW, Landscape::SupplyDayInYear(), Landscape::SupplyRain(), Landscape::SupplyTemp(), Landscape::SupplyYearNumber(), Population_Manager::TheArray, CfgInt::value(), and CfgFloat::value().

◆ DoLast()

void Rabbit_Population_Manager::DoLast ( void  )
protectedvirtual

Things to do after the EndStep.

For POM testing the following records have been added to the output:

  • The mean number of litters per female
  • Natal dispersal% for each sex
  • Lifetime reproductive success (no kits and mean litter size) (on death of rabbit)

Reimplemented from Population_Manager.

361 {
362  int today = m_TheLandscape->SupplyDayInYear();
363  // Do the output jobs
364  // Pesticide deaths
366  // Warren occupancy
375 }
static CfgInt cfg_warrenoccupancyrecordday("RABBIT_WARRENOCCUPANCYRECORDDAY", CFG_CUSTOM, 60)
Output control - the day in year for recording warren and population data.
void PesticideDeathRecordOutput()
Print pesticide death record to file.
Definition: Rabbit_Population_Manager.cpp:852
void WarrenOccupancyRecordOutput()
Print warren occupancy record to file.
Definition: Rabbit_Population_Manager.cpp:774

References cfg_warrenoccupancyrecordday, Population_Manager::m_TheLandscape, PesticideDeathRecordOutput(), Landscape::SupplyDayInYear(), CfgInt::value(), and WarrenOccupancyRecordOutput().

◆ FindClosestWarren()

Rabbit_Warren * Rabbit_Population_Manager::FindClosestWarren ( int  a_x,
int  a_y,
int  a_rank 
)

Finds the closest warren as the crow flies.

Parameters
[in]a_xthe x coordinate for the TL corner of the warren.
[in]a_ythe y coordinate for the TL corner of the warren.
[in]a_rankthe nth rank closest warren to return
Returns
a pointer to the nth rank closest warren. If none returns NULL.

Loops through all warrens and calculates the distance to a_x, a_y. Returns the one ranked 'a_rank' closest as the crow flies. Can handle up to 10 ranks - it will cause an error to ask for more. This is used for the occaisions where the closest warren is one the rabbit knows already, so don't ask for that one.

693 {
703  int results[10];
704  int dist;
705  TAnimal* ptrs[10];
706  for (int r = 0; r < 10; r++) {
707  results[ r ] = SimH*SimW;
708  ptrs[ r ] = NULL;
709  }
710  int sz = (int) TheArray[rob_Warren].size();
711  for (int i=0; i< sz; i++)
712  {
713  int X = TheArray[rob_Warren][i]->Supply_m_Location_x();
714  int Y = TheArray[rob_Warren][i]->Supply_m_Location_y();
715  dist = (int)sqrt( ((double( X - a_x )*double( X - a_x )) + (double( Y - a_y )*double( Y - a_y ))) );
716  for (int r=0; r<10; r++)
717  {
718  if (dist<=results[r])
719  {
720  for (int t=r+1; t<10; t++)
721  {
722  results[t]=results[t-1];
723  ptrs[t]=ptrs[t-1];
724  }
725  results[r]=dist;
726  ptrs[r]=TheArray[rob_Warren][i];
727  break;
728  }
729  }
730  }
731  Rabbit_Warren* rw = dynamic_cast<Rabbit_Warren*>(ptrs[ a_rank ]);
732  return rw;
733 }
The base class for all ALMaSS animal classes.
Definition: PopulationManager.h:205

References rob_Warren, Population_Manager::SimH, Population_Manager::SimW, and Population_Manager::TheArray.

Referenced by Rabbit_Male::st_EvaluateTerritory(), and Rabbit_Female::st_EvaluateTerritory().

◆ GetForageDay()

bool Rabbit_Population_Manager::GetForageDay ( )
inline

Get method for the forage day flag.

123  {
124  return m_forageday;
125  }

References m_forageday.

Referenced by Rabbit_Adult::EndStep(), Rabbit_Juvenile::st_Develop(), Rabbit_Young::st_Develop(), and Rabbit_Warren::st_WarrenBeing().

◆ GetGrowth()

double Rabbit_Population_Manager::GetGrowth ( int  a_age)
inline

Get method for the rabbit growth with age.

116  {
117 // if ((a_age < 0) || (a_age >= 3650)) {
118 // int rubbish = 1;
119 // }
120  return m_RabbitGrowth[ a_age ];
121  }

References m_RabbitGrowth.

Referenced by Rabbit_Adult::EndStep(), Rabbit_Adult::Rabbit_Adult(), Rabbit_Juvenile::Rabbit_Juvenile(), Rabbit_Juvenile::st_Develop(), and Rabbit_Young::st_Develop().

◆ IsBreedingSeason()

bool Rabbit_Population_Manager::IsBreedingSeason ( void  )
inline

◆ LifetimeReproAnalysis()

void Rabbit_Population_Manager::LifetimeReproAnalysis ( )
protected

Does analysis on the lifetime reproductive output file and saves the results to RabbitPOMSummary.txt.

1061  {
1062  /*
1063  % Success 0.66
1064  Average litters( of reproducers ) 4.39
1065  Av.Total Offspring 21.13
1066  Mean Repro Age 348.26
1067  Max Repro Age 2069.00
1068  */
1069  int Year, Day, Age, Offspring, Litter;
1070  double NoSuccessfulReproducers = 0;
1071  double NoOffspring = 0;
1072  double TotalAdults = 0;
1073  double ZeroLitters = 0;
1074  double TotalLitters = 0;
1075  double AvNoYoungLitter = 0;
1076  double AvLittersPerFemale = 0;
1077  double AvTotalOffspring = 0;
1078  double pctSuccess = 0;
1079  double MeanReproAge = 0;
1080  double SumReproAge = 0;
1081  double MaxReproAge = 0;
1082  double sumunderage = 0;
1083  double sumunderageoffspring = 0;
1084 
1085  ifstream ReproFile( "RabbitLifetimeReproRecord.txt", ios::in );
1086  // Read the header line
1087  char st[ 2000 ];
1088  ReproFile.getline( st, 2000 );
1089  ReproFile >> Year >> Day >> Age >> Offspring >> Litter;
1090  while (!ReproFile.eof()) {
1091  if (Year > 2000) {
1092  if (Age >= 304) {
1093  TotalAdults++;
1094  SumReproAge += Age - 304;
1095  if (Litter > 0) {
1096  TotalLitters += Litter;
1097  NoSuccessfulReproducers++;
1098  if (MaxReproAge < Age - 304) MaxReproAge = Age - 304;
1099  }
1100  else ZeroLitters++;
1101  NoOffspring += Offspring;
1102  }
1103  else if (Litter > 0) {
1104  sumunderage++;
1105  sumunderageoffspring += Offspring;
1106  }
1107  }
1108  ReproFile >> Year >> Day >> Age >> Offspring >> Litter;
1109  }
1110  if (TotalLitters > 0) AvNoYoungLitter = NoOffspring / TotalLitters;
1111  if (TotalAdults > 0) {
1112  MeanReproAge = SumReproAge / TotalAdults;
1113  pctSuccess = NoSuccessfulReproducers / TotalAdults;
1114  AvLittersPerFemale = TotalLitters / NoSuccessfulReproducers;
1115  }
1116  AvTotalOffspring = AvLittersPerFemale * AvNoYoungLitter;
1117  ofstream ofile( "RabbitPOMSummary.txt", ios::app );
1118  ofile << NoSuccessfulReproducers
1119  << '\t' << TotalLitters
1120  << '\t' << NoOffspring
1121  << '\t' << pctSuccess
1122  << '\t' << AvTotalOffspring
1123  << '\t' << AvNoYoungLitter
1124  << '\t' << AvLittersPerFemale
1125  << '\t' << MeanReproAge
1126  << '\t' << MaxReproAge
1127  << '\t' << sumunderage
1128  << '\t' << sumunderageoffspring << '\t';
1129  ofile.close();
1130 }

Referenced by ~Rabbit_Population_Manager().

◆ LoadWarrenLocations()

void Rabbit_Population_Manager::LoadWarrenLocations ( void  )
protected

Load warren locations.

If warren locations are not to be calculated then they are loaded from a standard file called "RabbitWarrenLocations.txt". If the wrong file is used there is no error checking and the result is usually a mysterious crash or strange results. Great care must be taken to ensure this does not happen.

611 {
616  ifstream ifile(cfg_warrenlocationsfile.value());
617  if ( !ifile.is_open() )
618  {
619  g_msg->Warn("Rabbit_Population_Manager::LoadWarrenLocations() Cannot open file: ", cfg_warrenlocationsfile.value());
620  exit( 1 );
621  }
622  int sz;
623  ifile >> sz;
624  for (int i=0; i< sz; i++)
625  {
626  int x,y,s;
627  ifile >> x >> y >> s;
628  struct_Rabbit sR;
629  sR.m_NPM = this;
630  sR.m_L = m_TheLandscape;
631  sR.m_x = x;
632  sR.m_y = y;
633  sR.m_soil = s;
634  CreateObjects(rob_Warren,NULL,&sR,1);
635  }
636  ifile.close();
637 }
static CfgStr cfg_warrenlocationsfile("RABBIT_WARRENLOCATIONSFILE", CFG_CUSTOM, "RabbitWarrenLocations.txt")
Input variable. The warren locations file.
const char * value(void)
Definition: configurator.h:152
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:59
class MapErrorMsg * g_msg
This pointer provides access the to the internal ALMaSS error message system.
Definition: maperrormsg.cpp:41

References cfg_warrenlocationsfile, CreateObjects(), g_msg, struct_Rabbit::m_L, struct_Rabbit::m_NPM, struct_Rabbit::m_soil, Population_Manager::m_TheLandscape, struct_Rabbit::m_x, struct_Rabbit::m_y, rob_Warren, CfgStr::value(), and MapErrorMsg::Warn().

Referenced by Rabbit_Population_Manager().

◆ NatalDispersalAnalysis()

void Rabbit_Population_Manager::NatalDispersalAnalysis ( )
protected

Does analysis on the natal dispersal output file and saves the results to RabbitPOMSummary.txt.

1133  {
1134  int year, day, bornx, borny, newx, newy, sex;
1135  int sedmales = 0;
1136  int sedfemales = 0;
1137  int dispmales = 0;
1138  int dispfemales = 0;
1139  double malenataldisp = 0;
1140  double femalenataldisp = 0;
1141  ifstream DispFile( "RabbitNatalDispersalRecord.txt", ios::in );
1142  // Read the header line
1143  char st[ 2000 ];
1144  DispFile.getline( st, 2000 );
1145  DispFile >> year >> day >> bornx >> borny >> newx >> newy >> sex;
1146  while (!DispFile.eof()) {
1147  if (year > 2000) {
1148  if ((bornx != newx) || (borny != newy)) {
1149  if (sex == 2) dispmales++; else dispfemales++;
1150  }
1151  else if (sex == 2) sedmales++; else sedfemales++;
1152  }
1153  DispFile >> year >> day >> bornx >> borny >> newx >> newy >> sex;
1154  }
1155  if ((dispmales + sedmales)>0) malenataldisp = dispmales / double( dispmales + sedmales );
1156  if ((dispfemales + sedfemales)>0) femalenataldisp = dispfemales / double( dispfemales + sedfemales );
1157  ofstream ofile( "RabbitPOMSummary.txt", ios::app );
1158  ofile << malenataldisp << '\t' << femalenataldisp << '\t';
1159  ofile.close();
1160 }

Referenced by ~Rabbit_Population_Manager().

◆ NatalDispersalRecordOutput()

void Rabbit_Population_Manager::NatalDispersalRecordOutput ( Rabbit_Base a_rabbit)

Records the natal dispersal.

If this method is called it records the current location as well as the location of birth to allow natal dispersal calculations.

913 {
918  APoint pt = a_rabbit->GetBornLocation();
919  m_NatalDispersalFile << pt.m_x << '\t' << pt.m_y << '\t' << a_rabbit->Supply_m_Location_x() << '\t' << a_rabbit->Supply_m_Location_y() << '\t' << a_rabbit->GetRabbitType() << endl;
920 }
A simple class defining an x,y coordinate set.
Definition: ALMaSS_Setup.h:53
int m_y
Definition: ALMaSS_Setup.h:56
int m_x
Definition: ALMaSS_Setup.h:55
int SupplyYear(void)
Definition: landscape.h:1611
APoint GetBornLocation()
Get location of birth.
Definition: Rabbit.h:258
RabbitObjectTypes GetRabbitType(void)
Get rabbit type.
Definition: Rabbit.h:218
ofstream m_NatalDispersalFile
For recording the natal dispersal of adults from birth to death.
Definition: Rabbit_Population_Manager.h:143
int Supply_m_Location_x()
Definition: PopulationManager.h:213
int Supply_m_Location_y()
Definition: PopulationManager.h:216

References Rabbit_Base::GetBornLocation(), Rabbit_Base::GetRabbitType(), m_NatalDispersalFile, Population_Manager::m_TheLandscape, APoint::m_x, APoint::m_y, TAnimal::Supply_m_Location_x(), TAnimal::Supply_m_Location_y(), Landscape::SupplyDayInYear(), and Landscape::SupplyYear().

Referenced by Rabbit_Base::BeginStep().

◆ NatalDispersalRecordOutputClose()

void Rabbit_Population_Manager::NatalDispersalRecordOutputClose ( )
protected

Closes the reproductive output file.

932 {
933  m_NatalDispersalFile.close();
934 }

References m_NatalDispersalFile.

Referenced by ~Rabbit_Population_Manager().

◆ NatalDispersalRecordOutputOpen()

void Rabbit_Population_Manager::NatalDispersalRecordOutputOpen ( )
protected

Opens the reproductive output file.

924 {
925  m_NatalDispersalFile.open("RabbitNatalDispersalRecord.txt", ios::out);
926  m_NatalDispersalFile << "Year" << '\t' << "Day" << '\t';
927  m_NatalDispersalFile << "Born_X" << '\t' << "Born_Y" << '\t' << "New_X" << '\t' << "New_Y" << '\t' << "Rabbit_Type" << endl;
928 }

References m_NatalDispersalFile.

Referenced by Rabbit_Population_Manager().

◆ PesticideDeathRecord()

void Rabbit_Population_Manager::PesticideDeathRecord ( RabbitObjectTypes  ob_type)

Records pesticide poisoning incidents.

769 {
770  m_PesticideDeaths[a_ob]++;
771 }

References m_PesticideDeaths.

Referenced by Rabbit_Base::GeneralOrganoPhosphate(), and Rabbit_Female::st_GiveBirth().

◆ PesticideDeathRecordOutput()

void Rabbit_Population_Manager::PesticideDeathRecordOutput ( )
protected

Print pesticide death record to file.

Simply records the number of different types of rabbits that died of direct pesticide poisoning and the date it happened.

853 {
858  for (int r = (int)rob_Young; r < (int)rob_foobar; r++)
859  {
861  }
862  m_PesticideDeathOFile << endl;
863 }
ofstream m_PesticideDeathOFile
The pesticide death output file.
Definition: Rabbit_Population_Manager.h:147

References m_PesticideDeathOFile, m_PesticideDeaths, Population_Manager::m_TheLandscape, rob_foobar, rob_Young, Landscape::SupplyDayInYear(), and Landscape::SupplyYear().

Referenced by DoLast().

◆ PesticideDeathRecordOutputClose()

void Rabbit_Population_Manager::PesticideDeathRecordOutputClose ( )
protected

Closes the pesticide death output file.

883 {
884  m_PesticideDeathOFile.close();
885 }

References m_PesticideDeathOFile.

Referenced by ~Rabbit_Population_Manager().

◆ PesticideDeathRecordOutputOpen()

void Rabbit_Population_Manager::PesticideDeathRecordOutputOpen ( )
protected

Opens pesticide death output file.

867 {
868  m_PesticideDeathOFile.open("RabbitPesticideDeathRecord.txt", ios::out);
869 }

References m_PesticideDeathOFile.

Referenced by Rabbit_Population_Manager().

◆ PreProcessWarrenLocations()

void Rabbit_Population_Manager::PreProcessWarrenLocations ( )
protected

This pre-scans the landscape and determines all potential warren locations on start-up.

Scans the landscape from random,random to width,height, then 0,0 to start location. Moves left to right, then top to bottom. At every location a rabbit warren is possible one is created with no population. Soil type determines the density of burrows possible and alters the requirements for fixed forage. Two options are availabe, 1. calculate the soiltype from the information present in the landscape (if this is present); 2. Read the soil type from a config variable and assume the whole landscape is of this type. see cfg_rabbit_fix_soiltype and cfg_rabbit_use_fixed_soiltype
Warrens cannot overlap their fixed areas (they can overlap forage though) and must contain a minimum proportion of fixed forage which varies with soil type.

If the warren position is possible then we need to assess the element contents. This should be above a minimum % fixed forage.

If forage percentages is OK then we can make a warren here, so an empty warren location is created. Note that the Rabbit_Warren constructor takes care of ensuring the warren is intiated to being 'virgin'.

379 {
388  cout << "Preprocessing Warren Locations" << endl;
389  int x = 0;
390  int y = 0;
391  int soil = 0;
392  for (int j=y; j<SimH-m_warrenfixedsize; j++)
393  {
394  for (int i=x; i<SimW-m_warrenfixedsize; i++)
395  {
396  if ( WarrenLegalPos(i,j) )
397  {
399  else
400  {
401  soil = m_TheLandscape->SupplySoilTypeR(i, j);
402  }
404  double pct = AssessPctForage(i,j);
405  if ((soil) != 3) // Soil type 3 is unsuitable therefore skipped
406  {
407  // Soil type 1 is sandy, 0 is chalk or otherwise hard soil
408  if (pct >= 1.0)
409  {
414  struct_Rabbit sR;
415  sR.m_NPM = this;
416  sR.m_L = m_TheLandscape;
417  sR.m_x = i;
418  sR.m_y = j;
419  sR.m_soil = soil;
420  CreateObjects(rob_Warren, NULL, &sR, 1);
421  --i += m_warrenfixedsize;
422  if (static_cast<unsigned>(TheArray.size()) % 1000 == 0) cout << TheArray.size() << '\t';
423  }
424  }
425  }
426  }
427  }
428 }
static CfgInt cfg_rabbit_fix_soiltype("RABBIT_FIX_SOIL_TYPE", CFG_CUSTOM, 0)
Input variable. The soil type applied to all warrens.
static CfgBool cfg_rabbit_use_fixed_soiltype("RABBIT_USE_FIXED_SOIL_TYPE", CFG_CUSTOM, true)
Input variable. Assume fixed soil type or use landscape info?
int SupplySoilTypeR(int a_x, int a_y)
Returns the soil type in rabbit warren reference numbers.
Definition: landscape.h:464
bool WarrenLegalPos(int &a_x, int a_y)
Tests the warrens list to see if this position is legal.
Definition: Rabbit_Population_Manager.cpp:431
double AssessPctForage(int a_x, int a_y)
Assesses the percentage of forage for a location assuming max warren size.
Definition: Rabbit_Population_Manager.cpp:552

References AssessPctForage(), cfg_rabbit_fix_soiltype, cfg_rabbit_use_fixed_soiltype, CreateObjects(), struct_Rabbit::m_L, struct_Rabbit::m_NPM, struct_Rabbit::m_soil, Population_Manager::m_TheLandscape, m_warrenfixedsize, struct_Rabbit::m_x, struct_Rabbit::m_y, rob_Warren, Population_Manager::SimH, Population_Manager::SimW, Landscape::SupplySoilTypeR(), Population_Manager::TheArray, CfgInt::value(), CfgBool::value(), and WarrenLegalPos().

Referenced by Rabbit_Population_Manager().

◆ ReproOutputRecordOutput()

void Rabbit_Population_Manager::ReproOutputRecordOutput ( Rabbit_Female a_female)

Print reproductive record to file.

Records the age and reproductive output of the rabbit and the date it died

889 {
894  m_ReproOutputFile << '\t' << a_female->GetAge() << '\t' << a_female->GetTotalOffspring() << '\t' << a_female->GetTotalLitters() << endl;
895 }
int GetAge(void)
Get age method.
Definition: Rabbit.h:222
int GetTotalOffspring()
Definition: Rabbit.h:464
int GetTotalLitters()
Definition: Rabbit.h:465
ofstream m_ReproOutputFile
For recording the lifetime reproductive success.
Definition: Rabbit_Population_Manager.h:145

References Rabbit_Base::GetAge(), Rabbit_Female::GetTotalLitters(), Rabbit_Female::GetTotalOffspring(), m_ReproOutputFile, Population_Manager::m_TheLandscape, Landscape::SupplyDayInYear(), and Landscape::SupplyYear().

Referenced by Rabbit_Female::st_Dying().

◆ ReproOutputRecordOutputClose()

void Rabbit_Population_Manager::ReproOutputRecordOutputClose ( )
protected

Closes the reproductive output file.

907 {
908  m_ReproOutputFile.close();
909 }

References m_ReproOutputFile.

Referenced by ~Rabbit_Population_Manager().

◆ ReproOutputRecordOutputOpen()

void Rabbit_Population_Manager::ReproOutputRecordOutputOpen ( )
protected

Opens the reproductive output file.

899 {
900  m_ReproOutputFile.open( "RabbitLifetimeReproRecord.txt", ios::out );
901  m_ReproOutputFile << "Year" << '\t' << "Day" << '\t';
902  m_ReproOutputFile << '\t' << "Age" << '\t' << "Offpring" << '\t' << "Litters" << endl;
903 }

References m_ReproOutputFile.

Referenced by Rabbit_Population_Manager().

◆ SaveWarrenLocations()

void Rabbit_Population_Manager::SaveWarrenLocations ( void  )
protected

Save warren locations.

Save the warren locations to "RabbitWarrenLocations.txt" so that these can be loaded again without having to go through the pre-process warren network step each time a landscape is used.

589 {
594  ofstream ofile(cfg_warrenlocationsfile.value());
595  if ( !ofile.is_open() )
596  {
597  g_msg->Warn("Rabbit_Population_Manager::SaveWarrenLocations() Cannot open file: ", cfg_warrenlocationsfile.value());
598  exit( 1 );
599  }
600  int sz = (int) TheArray[rob_Warren].size();
601  ofile << sz << endl;
602  for (int i=0; i< sz; i++)
603  {
604  Rabbit_Warren* awarren = dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][i]);
605  ofile << awarren->Supply_m_Location_x() - m_warrenfixedsizediv2 << '\t' << awarren->Supply_m_Location_y() - m_warrenfixedsizediv2 << '\t' << awarren->GetSoilType() << endl;
606  }
607  ofile.close();
608 }
int GetSoilType(void)
Gets the warren soil type.
Definition: Rabbit.h:632

References cfg_warrenlocationsfile, g_msg, Rabbit_Warren::GetSoilType(), m_warrenfixedsizediv2, rob_Warren, TAnimal::Supply_m_Location_x(), TAnimal::Supply_m_Location_y(), Population_Manager::TheArray, CfgStr::value(), and MapErrorMsg::Warn().

Referenced by Rabbit_Population_Manager().

◆ SupplyAllBigRabbits()

unsigned Rabbit_Population_Manager::SupplyAllBigRabbits ( )
inline

Returns the total number of rabbits.

110  {
111  unsigned sum = 0;
112  for (unsigned r = rob_Male; r < rob_foobar; r++) sum += (unsigned) TheArray[r].size();
113  return sum;
114  }

References rob_foobar, rob_Male, and Population_Manager::TheArray.

Referenced by Rabbit_Warren::CalcDisease().

◆ TheAOROutputProbe()

void Rabbit_Population_Manager::TheAOROutputProbe ( )
protectedvirtual

Calculates the AOR data for output for the Rabbit

Reimplemented from Population_Manager.

1163  {
1165 }
virtual void DoProbe(int a_lifestage)
Definition: AOR_Probe.cpp:59
AOR_Probe * m_AOR_Probe
Definition: PopulationManager.h:526

References AOR_Probe::DoProbe(), Population_Manager::m_AOR_Probe, and rob_Female.

◆ WarrenLegalPos()

bool Rabbit_Population_Manager::WarrenLegalPos ( int &  a_x,
int  a_y 
)
protected

Tests the warrens list to see if this position is legal.

Parameters
[in]a_xThe x-coordinate to assess
[in]a_yThe x-coordinate to assess
Returns
Whether the location is a legal one for a warren

Loops through all warrens and asks whether they are closer than m_warrenfixedsize, if so returns false. Must loop through all warrens to return true.

Todo:
Use a temporary binary map to achieve this without the loop - speed optimisation if we have time.
432 {
442  // If it is not in a warren already then we are legal here.
443  int sz = (int) TheArray[rob_Warren].size();
444  for (int i=0; i< sz; i++)
445  {
446  APoint pt = dynamic_cast<Rabbit_Warren*>(TheArray[rob_Warren][i])->SupplyPoint();
447  if ((abs(pt.m_x-a_x) < m_warrenfixedsize) && (abs(pt.m_y-a_y) < m_warrenfixedsize))
448  {
449  a_x += m_warrenfixedsize;
450  return false;
451  }
452  }
453  return true;
454 }

References ClassifyHabitat(), Population_Manager::m_TheLandscape, m_warrenfixedsize, m_warrenfixedsizediv2, APoint::m_x, APoint::m_y, rob_Warren, Landscape::SupplyElementType(), Population_Manager::TheArray, and torh_Forage.

Referenced by PreProcessWarrenLocations().

◆ WarrenOccupancyRecordOutput()

void Rabbit_Population_Manager::WarrenOccupancyRecordOutput ( )
protected

Print warren occupancy record to file.

Produces a record of mean warren occupancy, number of burrows, disease level, and a a measure of variation in occupancy (CV of occupancy).
For convenience some global stats on population numbers are also produced here.

774  {
779  ofstream warrenrecord( "WarrenOccupancyRecord.txt", ios::app );
780  double occupancy = 0;
781  double var_occupancy = 0;
782  double sumsqr = 0.0;
783  double totalrabbits = 0;
784  double burrows = 0;
785  double disease = 0;
786  int warrensoccupied = 0;
787  int kits = 0;
788  int juvs = 0;
789  int ads = 0;
790  int breedingfemales = 0;
791  double breedingfemalesAv = 0;
792  int oneyroldfemales = 0;
793  int nonbreedingfemales = 0;
794  int litters = 0;
795  double lrc = 0;
796  double n = (double)TheArray[ rob_Warren ].size();
797  for (unsigned i = 0; i < TheArray[ rob_Warren ].size(); i++) {
798  Rabbit_Warren* warren = dynamic_cast<Rabbit_Warren*>(TheArray[ rob_Warren ][ i ]);
799  double occ = warren->GetCarryingCapacityRatio();
800  occupancy += occ;
801  sumsqr += occ * occ;
802  totalrabbits += warren->GetPopulationSize();
803  if (warren->GetPopulationSize()>0) warrensoccupied++;
804  burrows += warren->GetCarryingCapacity();
805  disease += warren->GetDiseaseConstant();
806  kits += warren->GetRabbitProductionRecord( rob_Young );
807  juvs += warren->GetRabbitProductionRecord( rob_Juvenile );
808  ads += warren->GetRabbitProductionRecord( rob_Male );
809  ads += warren->GetRabbitProductionRecord( rob_Female );
810  warren->UpdateThisYearsBreeders();
811  breedingfemales += warren->GetThisYearsBreeders();
812  breedingfemalesAv += warren->GetThisYearsBreedersAv();
813  oneyroldfemales += warren->GetThisYears1yrOldFemales();
814  nonbreedingfemales += warren->GetThisYearsNonBreeders();
815  litters += warren->GetLittersThisYear();
816  lrc += warren->GetLitterReabsortionConst();
818  }
819  double littersperfemale = 0;
820  double CV_occ = 0;
821  if ((occupancy > 0) && (ads > 0)) {
822  var_occupancy = (sumsqr - (occupancy*occupancy) / n) / (n - 1);
823  if (var_occupancy < 0) var_occupancy = 0.0; // Rounding errors cause this
824  occupancy /= n;
825  burrows /= n;
826  disease /= n;
827  totalrabbits /= n;
828  kits /= (int)n;
829  juvs /= (int)n;
830  ads /= (int)n;
831  CV_occ = sqrt( var_occupancy ) / occupancy;
832  if (breedingfemales > 0) littersperfemale = litters / double( breedingfemales );
833  }
834  else {
835  var_occupancy = 0;
836  occupancy = 0;
837  burrows = 0;
838  disease = 0;
839  totalrabbits = 0;
840  kits = 0;
841  juvs = 0;
842  ads = 0;
843  CV_occ = 0;
844  }
845  lrc /= n;
846  warrenrecord << m_TheLandscape->SupplyYearNumber() << '\t' << m_TheLandscape->SupplyDayInYear() << '\t' << (int)n << '\t' << warrensoccupied << '\t' << burrows << '\t' << totalrabbits << '\t' << disease << '\t' << occupancy << '\t' << CV_occ << '\t' << kits << '\t' << juvs << '\t' << ads;
847  for (int r = (int)rob_Young; r < rob_Warren; r++) warrenrecord << '\t' << TheArray[ r ].size();
848  warrenrecord << '\t' << breedingfemales << '\t' << breedingfemalesAv << '\t' << oneyroldfemales << '\t' << nonbreedingfemales << '\t' << littersperfemale << '\t' << lrc << '\t' << litters << endl;
849 }
int GetLittersThisYear()
Returns the number litters produced in the last 12 months.
Definition: Rabbit.h:670
int GetThisYearsBreeders()
Returns the number of females breeding this year.
Definition: Rabbit.h:654
int GetThisYearsNonBreeders()
Returns the number of females not breeding this year but older than 1 year.
Definition: Rabbit.h:674
double GetDiseaseConstant(void)
Returns the warrens current disease constant.
Definition: Rabbit.h:580
void ResetAllRabbitProductionRecord(void)
Reset data about production of rabbits throughout year.
Definition: Rabbit.h:588
double GetCarryingCapacityRatio()
Checks whether all possible burrows are filled with rabbits. This is updated daily by Rabbit_Warren::...
Definition: Rabbit.h:576
int GetThisYears1yrOldFemales()
Returns the number of 1yr old females.
Definition: Rabbit.h:666
int GetRabbitProductionRecord(RabbitObjectTypes YoungType)
Get data about production of rabbits throughout year.
Definition: Rabbit.h:584
int GetPopulationSize()
Gets the total warren population of rabbits.
Definition: Rabbit.h:572
double GetThisYearsBreedersAv()
Returns the number of females breeding this year.
Definition: Rabbit.h:658
double GetLitterReabsortionConst(void)
Returns litter reabsorption chance.
Definition: Rabbit.h:650
void UpdateThisYearsBreeders()
Calculates and stores the number of breeders and non-breeders.
Definition: Rabbit.cpp:1821

References Rabbit_Warren::GetCarryingCapacity(), Rabbit_Warren::GetCarryingCapacityRatio(), Rabbit_Warren::GetDiseaseConstant(), Rabbit_Warren::GetLitterReabsortionConst(), Rabbit_Warren::GetLittersThisYear(), Rabbit_Warren::GetPopulationSize(), Rabbit_Warren::GetRabbitProductionRecord(), Rabbit_Warren::GetThisYears1yrOldFemales(), Rabbit_Warren::GetThisYearsBreeders(), Rabbit_Warren::GetThisYearsBreedersAv(), Rabbit_Warren::GetThisYearsNonBreeders(), Population_Manager::m_TheLandscape, Rabbit_Warren::ResetAllRabbitProductionRecord(), rob_Female, rob_Juvenile, rob_Male, rob_Warren, rob_Young, Landscape::SupplyDayInYear(), Landscape::SupplyYearNumber(), Population_Manager::TheArray, and Rabbit_Warren::UpdateThisYearsBreeders().

Referenced by DoLast().

◆ WarrenOccupancyRecordOutputClose()

void Rabbit_Population_Manager::WarrenOccupancyRecordOutputClose ( )
protected

Closes the warren occupancy output file.

938 {
939  m_WarrenOccupancyFile.close();
940 }
ofstream m_WarrenOccupancyFile
The warren occupancy output file.
Definition: Rabbit_Population_Manager.h:141

References m_WarrenOccupancyFile.

Referenced by ~Rabbit_Population_Manager().

◆ WarrenOccupancyRecordOutputOpen()

void Rabbit_Population_Manager::WarrenOccupancyRecordOutputOpen ( )
protected

Opens the warren occupancy output file.

873 {
874  m_WarrenOccupancyFile.open("WarrenOccupancyRecord.txt", ios::out);
875  m_WarrenOccupancyFile << "Year" << '\t' << "Day" << '\t' << "No. Warrens" << '\t' << "No.Occ.Warrens" << '\t' << "Mean Burrows" << '\t' << "Mean Rabbits" << '\t' << "Mean Disease"
876  << '\t' << "Mean Occupancy" << '\t' << "CV Occupancy" << '\t' << "Mean Kits" << '\t' << "Mean Juvs" << '\t' << "Mean Ads" << '\t' << "TotalYoung" << '\t' << "TotalJuvs"
877  << '\t' << "TotalMales" << '\t' << "TotalFemales" << '\t' << "BreedingFemales" << '\t' << "BreedingDensityAv" << '\t' << "1yr old females" << '\t' << "NonBreedingFems.>1yr"
878  << '\t' << "Littersperfemale" << '\t' << "lrc" << '\t' << "litters" << endl;
879 }

References m_WarrenOccupancyFile.

Referenced by Rabbit_Population_Manager().

◆ WarrenOutputAnalysis()

void Rabbit_Population_Manager::WarrenOutputAnalysis ( )
protected

Does analysis on the warren output file and saves the results to RabbitPOMSummary.txt.

943  {
944  double Year, Day, NoWarrens, NoOccWarrens, MeanBurrows, MeanRabbits, MeanDisease, MeanOccupancy, CVOccupancy, MeanKits, MeanJuvs, MeanAds, TotalYoung, TotalJuvs, TotalMales,
945  TotalFemales, BreedingFemales, yroldfemales, NonBreedingFems;
946  vector<double> totalfemales;
947  vector<double> totalbrfemalesdensity;
948  vector<double> nonbreedingdensity;
949  vector<double> yrolddensity;
950  vector<double> breedingdensity;
951  vector<double> yearlingpct;
952  vector<double> kitsperfemale;
953 
954  double meantotalbrpop;
955  double maxbreedingpop = -1;
956  double minbreedingpop = 100000;
957  double maxyroldspct = -1;
958  double minyroldspct = 100000;
959  double correlation;
960  double correlation_b;
961  double littersperfemale;
962  double lrc;
963  double BreedingDensityAv;
964  double litters;
965 
966 
967  ifstream WarrenOccupancyFile( "WarrenOccupancyRecord.txt", ios::in );
968  // Read the header line
969  char st[ 2000 ];
970  WarrenOccupancyFile.getline( st, 2000 );
971  while (!WarrenOccupancyFile.eof()) {
972  WarrenOccupancyFile >> Year >> Day >> NoWarrens >> NoOccWarrens >> MeanBurrows >> MeanRabbits >> MeanDisease
973  >> MeanOccupancy >> CVOccupancy >> MeanKits >> MeanJuvs >> MeanAds >> TotalYoung >> TotalJuvs
974  >> TotalMales >> TotalFemales >> BreedingFemales >> BreedingDensityAv >> yroldfemales >> NonBreedingFems >> littersperfemale >> lrc >> litters;
975  // Here we create the actual data that we need
976  // We want:
977  // - correlation between total breeding pop and 1yr olds
978  // - mean of total breeding pop
979  // - mean of 1yr olds
980  // - range max-min of total breeding pop
981  // - range max-min of 1yr olds
982  if ((yroldfemales + BreedingFemales + NonBreedingFems) > 0) {
983  yearlingpct.push_back( yroldfemales / (yroldfemales + BreedingFemales + NonBreedingFems) );
984  totalbrfemalesdensity.push_back( (yroldfemales + BreedingFemales + NonBreedingFems) / 2.0 );
985  totalfemales.push_back( (BreedingFemales + NonBreedingFems) / 2.0 );
986  breedingdensity.push_back( BreedingFemales / 2.0 );
987  nonbreedingdensity.push_back( NonBreedingFems / 2.0 );
988  yrolddensity.push_back( yroldfemales / 2.0 );
989  kitsperfemale.push_back( littersperfemale );
990  }
991  else {
992  // All dead so save the results
993  ofstream ofile( "RabbitPOMSummary.txt", ios::app );
994  ofile << 0
995  << '\t' << 0
996  << '\t' << 0
997  << '\t' << 0
998  << '\t' << 0
999  << '\t' << 0
1000  << '\t' << 0 << endl;
1001  ofile.close();
1002  return;
1003  }
1004  }
1005  WarrenOccupancyFile.close();
1006  // Now we have all the useful data we can create the stats for this analysis
1007  //
1008  // Get the ranges skipping the first 10 years
1009  int sz = static_cast<int>(yearlingpct.size());
1010  double sumx = 0;
1011  double sumx2 = 0;
1012  double sumy = 0;
1013  double sumy2 = 0;
1014  double sumxy = 0;
1015  double sumx_b = 0;
1016  double sumx2_b = 0;
1017  double sumy_b = 0;
1018  double sumy2_b = 0;
1019  double sumxy_b = 0;
1020  double n = sz - 1 - 10;
1021  // Do the correlation for yearlingpct and total female density
1022  for (int i = 10; i < sz - 1; i++) {
1023  if (totalbrfemalesdensity[ i ]>maxbreedingpop)maxbreedingpop = totalbrfemalesdensity[ i ];
1024  if (totalbrfemalesdensity[ i ] < minbreedingpop)minbreedingpop = totalbrfemalesdensity[ i ];
1025  if (yearlingpct[ i ] > maxyroldspct) maxyroldspct = yearlingpct[ i ];
1026  if (yearlingpct[ i ] < minyroldspct) minyroldspct = yearlingpct[ i ];
1027  sumx += totalbrfemalesdensity[ i ];
1028  sumx2 += totalbrfemalesdensity[ i ] * totalbrfemalesdensity[ i ];
1029  sumy += yearlingpct[ i ];
1030  sumy2 += yearlingpct[ i ] * yearlingpct[ i ];
1031  sumxy += totalbrfemalesdensity[ i ] * yearlingpct[ i ];
1032  }
1033  meantotalbrpop = sumx / n;
1034  double intermediate = (n*sumxy) - (sumx*sumy);
1035  correlation = intermediate / sqrt( ((n*sumx2) - (sumx*sumx))*((n*sumy2) - (sumy*sumy)) );
1036  //
1037  n = n - 1;
1038  for (int i = 10; i < sz - 2; i++) {
1039  // Here we need the numbers from the year before
1040  sumx_b += totalfemales[ i ];
1041  sumx2_b += totalfemales[ i ] * totalfemales[ i ];
1042  sumy_b += kitsperfemale[ i+1 ];
1043  sumy2_b += kitsperfemale[ i+1 ] * kitsperfemale[ i+1 ];
1044  sumxy_b += totalfemales[ i ] * kitsperfemale[ i+1 ];
1045  }
1046  intermediate = (n*sumxy_b) - (sumx_b*sumy_b);
1047  correlation_b = intermediate / sqrt( ((n*sumx2_b) - (sumx_b*sumx_b))*((n*sumy2_b) - (sumy_b*sumy_b)) );
1048  // Now save the results
1049  ofstream ofile( "RabbitPOMSummary.txt", ios::app );
1050  ofile << meantotalbrpop
1051  << '\t' << maxbreedingpop
1052  << '\t' << minbreedingpop
1053  << '\t' << maxyroldspct
1054  << '\t' << minyroldspct
1055  << '\t' << correlation
1056  << '\t' << correlation_b << endl;
1057  ofile.close();
1058 }

Referenced by ~Rabbit_Population_Manager().

Member Data Documentation

◆ m_forageday

bool Rabbit_Population_Manager::m_forageday
protected

Flag to record whether today is a possible forage day.

Referenced by DoFirst(), and GetForageDay().

◆ m_NatalDispersalFile

ofstream Rabbit_Population_Manager::m_NatalDispersalFile
protected

For recording the natal dispersal of adults from birth to death.

Referenced by NatalDispersalRecordOutput(), NatalDispersalRecordOutputClose(), and NatalDispersalRecordOutputOpen().

◆ m_PesticideDeathOFile

ofstream Rabbit_Population_Manager::m_PesticideDeathOFile
protected

◆ m_PesticideDeaths

int Rabbit_Population_Manager::m_PesticideDeaths[rob_foobar]
protected

Holds the number of rabbits killed each day by pesticides.

Referenced by DoFirst(), PesticideDeathRecord(), and PesticideDeathRecordOutput().

◆ m_rabbitBreedingSeason

bool Rabbit_Population_Manager::m_rabbitBreedingSeason
protected

◆ m_RabbitGrowth

double Rabbit_Population_Manager::m_RabbitGrowth[3650]
protected

Holds daily growth potential of rabbits for each day

Referenced by GetGrowth(), and Rabbit_Population_Manager().

◆ m_ReproOutputFile

ofstream Rabbit_Population_Manager::m_ReproOutputFile
protected

For recording the lifetime reproductive success.

Referenced by ReproOutputRecordOutput(), ReproOutputRecordOutputClose(), and ReproOutputRecordOutputOpen().

◆ m_reproswitchbuffer

int Rabbit_Population_Manager::m_reproswitchbuffer
protected

Prevents continuous breeding season switching.

Referenced by CheckForRabbitBreedingConditions(), and Rabbit_Population_Manager().

◆ m_warrenfixedsize

int Rabbit_Population_Manager::m_warrenfixedsize
protected

Holds an input variable for max warren size in m

Referenced by AssessPctForage(), CreateObjects(), PreProcessWarrenLocations(), Rabbit_Population_Manager(), and WarrenLegalPos().

◆ m_warrenfixedsizediv2

int Rabbit_Population_Manager::m_warrenfixedsizediv2
protected

Half max warren size in m - for speed

Referenced by Rabbit_Population_Manager(), SaveWarrenLocations(), and WarrenLegalPos().

◆ m_WarrenOccupancyFile

ofstream Rabbit_Population_Manager::m_WarrenOccupancyFile
protected

The warren occupancy output file.

Referenced by WarrenOccupancyRecordOutputClose(), and WarrenOccupancyRecordOutputOpen().


The documentation for this class was generated from the following files: